<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;

use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
    #定义view路径
    protected $viewRootPath;
    protected $viewDocument;

    protected function success($info = '', $url = '', $data = [], $code = 200)
    {
        $this->ajaxRuten($code, $info, $url, $data);
    }

    protected function error($info = '', $url = '', $data = [], $code = 500)
    {
        $this->ajaxRuten($code, $info, $url, $data);
    }

    private function ajaxRuten($code, $info, $url, $data)
    {
        header('content-type:application/json;charset=utf8');
        exit(json_encode([
            'code' => $code,
            'info' => $info,
            'url' => $url,
            'data' => $data
        ]));
    }
}
